<extend name="Public/base" />

<block name="body">
	<!-- 标题栏 -->
	<div class="main-title">
		<h2>发货详情</h2>
	</div>
	<div class="cf"></div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
    	
	    <form action="{:U('update_return_status')}" method="post" class="form-horizontal">
			<table class="">
		    <thead>
		        <tr>
				<th class="" colspan="5">
					<center>退货详情</center>
				</th>
				</tr>
		    </thead>
		    <tbody>
				<notempty name="_list">
				<volist name="_list" id="vo">
				<tr>
					<td width="10%"><img src="{$vo.picture|get_cover='path'}" style="width:40%;"/></td>
					<td width="30%">{$vo.name}</td>
					<td width="8%">￥{$vo.price}</td>
					<td width="8%">数量：{$vo.num}</td>
				</tr>
				</volist>
				<tr>
					<td colspan="5">退货时间：{$data.return_time|getDateFormat=###}</td>
				</tr>
				<tr>
					<td colspan="5">退货状态：
		    			<font color="red"><switch name="data.return_status">
		    				<case value="2">审核中</case>
		    				<case value="3">审核通过</case>
		    				<case value="4">未通过审核</case>
		    				<case value="5">退货中</case>
		    				<case value="6">厂家已收货</case>
		    				<case value="7">退款中</case>
		    				<case value="8">退款完成</case>
		    				<case value="9">取消退款</case>
		    				<case value="10">用户撤销</case>
		    			</switch></font>
	    			</td>
				</tr>
				<tr>
					<td colspan="5">退货金额：￥{$returnAllMoney}</td>
				</tr>
				<tr>
					<td colspan="5">退货理由：{$data.return_msg}</td>
				</tr>
				<tr>
					<td>买家收货信息</td>
					<td colspan="4">
						收货人：{$data.name}
						联系电话：{$data.phone}
						联系地址：{$data.pro_id|getAreaName=###} {$data.city_id|getAreaName=###} {$data.area_id|getAreaName=###} {$data.address}
						邮编：{$data.code|default='无'}
					</td>
				</tr>
				<tr>
					<td>厂家收货信息</td>
					<td colspan="4">
						收货人：{$cdata.name}
						联系电话：{$cdata.phone}
						联系地址：{$cdata.address}
						邮编：{$cdata.code|default='无'}
					</td>
				</tr>
				<tr>
					<td>买家物流信息</td>
					<td colspan="4">
						<label class="item-label" style="display: inline;">物流名称：{$data.wl_name|default="无"}</label>
						<label class="item-label" style="display: inline;">运货单号：{$data.wl_order|default="无"}</label>
						<label class="item-label" style="display: inline;">用户留言：{$data.user_msg|default="无"}</label>
						<notempty name="data.wl_order">
							<a href="javascript:void(0);" class="wuliu">查看物流信息</a>
						</notempty>
					</td>
				</tr>
				<tr>
					<input type="hidden" name="return_price" id="return_price" value="{$returnAllMoney}">
					<input type="hidden" name="order_id" id="order_id" value="{$data.order_id}">
					<input type="hidden" name="order" id="order" value="{$data.order}">
					<td colspan="5">
						<switch name="data.return_status">
		    				<case value="2">
								<a class="btn sure_verify" href="javascript::">确 认 审 核</a>
								<a class="btn cancel_verify" href="javascript::">取 消 审 核</a>
		    				</case>
		    				<case value="3"><a class="btn" href="javascript::">审核通过</a></case>
		    				<case value="4"></case>
		    				<case value="5">
		    					<a class="btn sureGoods" href="javascript::">确认收货</a>
		    				</case>
		    				<case value="6">
		    					<a class="btn sureReturn" href="javascript::">确认退款</a>
		    					<a class="btn cancelReturn" href="javascript::">取消退款</a>
		    				</case>
		    				<case value="7"><a class="btn" href="javascript::">退款中</a></case>
		    				<case value="8"><a class="btn" href="javascript::">退款完成</a></case>
		    				<case value="9"></case>
		    				<case value="10"><a class="btn" href="javascript::">用户撤销</a></case>
		    			</switch>
	    			</td>
				</tr>
				<else/>
				<td colspan="5" class="text-center"> aOh! 暂时还没有内容! </td>
				</notempty>
			</tbody>
		    </table>
	    </form>
	    <!-- 物流信息开始 -->
	   <!--  <table class="wuliu_table" style="display:none;">
		    <thead>
		        <tr>
					<th class="">时间</th>
					<th class="" colspan="4">物流信息</th>
				</tr>
		    </thead>
		    <tbody>
		    	<notempty name="list">
		    	<volist name="list" id="v" key="k">
				<tr>
					<td>{$v.ftime}</td>
					<td>{$v.context}</td>
				</tr>
				</volist>
				<else />
				<td colspan="5" class="text-center"> aOh! 暂时还没有物流信息! </td>
				</notempty>
			</tbody>
		</table> -->
		<div class="wuliu_table" style="display:none;">
			<iframe name="kuaidi100" src="http://www.kuaidi100.com/chaxun?com={$data.wl_name|getCompanyCode=###}&nu={$data.wl_order}" width="960" height="880" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>
		</div>
		<!-- 物流信息结束 -->
	</div>
</block>

<block name="script">
	<script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
	<script type="text/javascript" src="__JS__/common.js"></script>
	<script type="text/javascript">
		$(function(){
			var order = $('#order').val();
			var order_id = $('#order_id').val();
			//确认审核
			$('.sure_verify').click(function(){
				update_status(order_id, order, 3);
			});
			//未通过审核
			$('.cancel_verify').click(function(){
				update_status(order_id, order, 4);
			});
			//查看物流信息
			$('.wuliu').click(function(){
				$('.wuliu_table').slideToggle('slow');
			});
			//确认收货
			$('.sureGoods').click(function(){
				// update_status(order_id, order, 6);
				if(!confirm('确认要执行该操作吗?')){
	                return false;
	            }
	            $.get("{:U('update_return_status')}", {order: order, order_id: order_id, return_status: 6}, function(r){
	            	if(r.status){
	            		alert("退款成功！");
	            		location.reload();
	            	}else{
	            		alert("退款失败！");
	            		location.reload();
	            	}
	            }, 'json');
			});
			//取消退款
			$('.cancelReturn').click(function(){
				update_status(order_id, order, 9);
			});
			//确认退款
			$('.sureReturn').click(function(){
				// if(!confirm('确认要执行该操作吗?')){
	   //              return false;
	   //          }
	   //          var return_price = $('#return_price').val();
	   //          $.post("{:U('sureReturnMoney')}", {order: order, return_price: return_price, order_id: order_id}, function(r){
	   //          	if(r.status){
	   //          		alert("退款成功！");
	   //          		location.reload();
	   //          	}else{
	   //          		alert("退款失败！");
	   //          		location.reload();
	   //          	}
	   //          }, 'json');
	            	update_status(order_id, order, 8);
			});
		});

		function update_status(order_id, order, return_status){
			var url = "{:U('update_return_status')}";
			if( url.indexOf('?')>0 ){
	            url += '&order_id=' + order_id + '&order=' + order + '&return_status=' + return_status;
	        }else{
	            url += '?order_id=' + order_id + '&order=' + order + '&return_status=' + return_status;
	        }
			window.location.href = url;
		}
	    //导航高亮
	    highlight_subnav('{:U('Order/index')}');
	</script>
</block>
